home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / libdevmapper-event.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-10-04  |  3.9 KB  |  107 lines

  1. /*
  2.  * Copyright (C) 2005-2007 Red Hat, Inc. All rights reserved.
  3.  *
  4.  * This file is part of the device-mapper userspace tools.
  5.  *
  6.  * This copyrighted material is made available to anyone wishing to use,
  7.  * modify, copy, or redistribute it subject to the terms and conditions
  8.  * of the GNU Lesser General Public License v.2.1.
  9.  *
  10.  * You should have received a copy of the GNU Lesser General Public License
  11.  * along with this program; if not, write to the Free Software Foundation,
  12.  * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  13.  */
  14.  
  15. /*
  16.  * Note that this file is released only as part of a technology preview
  17.  * and its contents may change in future updates in ways that do not
  18.  * preserve compatibility.
  19.  */
  20.  
  21. #ifndef LIB_DMEVENT_H
  22. #define LIB_DMEVENT_H
  23.  
  24. #include <stdint.h>
  25.  
  26. /*
  27.  * Event library interface.
  28.  */
  29.  
  30. enum dm_event_mask {
  31.     DM_EVENT_SETTINGS_MASK  = 0x0000FF,
  32.     DM_EVENT_SINGLE        = 0x000001, /* Report multiple errors just once. */
  33.     DM_EVENT_MULTI        = 0x000002, /* Report all of them. */
  34.  
  35.     DM_EVENT_ERROR_MASK     = 0x00FF00,
  36.     DM_EVENT_SECTOR_ERROR    = 0x000100, /* Failure on a particular sector. */
  37.     DM_EVENT_DEVICE_ERROR    = 0x000200, /* Device failure. */
  38.     DM_EVENT_PATH_ERROR    = 0x000400, /* Failure on an io path. */
  39.     DM_EVENT_ADAPTOR_ERROR    = 0x000800, /* Failure of a host adaptor. */
  40.  
  41.     DM_EVENT_STATUS_MASK    = 0xFF0000,
  42.     DM_EVENT_SYNC_STATUS    = 0x010000, /* Mirror synchronization completed/failed. */
  43.     DM_EVENT_TIMEOUT    = 0x020000, /* Timeout has occured */
  44.  
  45.     DM_EVENT_REGISTRATION_PENDING = 0x1000000, /* Monitor thread is setting-up/shutting-down */
  46. };
  47.  
  48. #define DM_EVENT_ALL_ERRORS DM_EVENT_ERROR_MASK
  49.  
  50. struct dm_event_handler;
  51.  
  52. struct dm_event_handler *dm_event_handler_create(void);
  53. void dm_event_handler_destroy(struct dm_event_handler *dmevh);
  54.  
  55. /*
  56.  * Path of shared library to handle events.
  57.  *
  58.  * All of dso, device_name and uuid strings are duplicated, you do not
  59.  * need to keep the pointers valid after the call succeeds. Thes may
  60.  * return -ENOMEM though.
  61.  */
  62. int dm_event_handler_set_dso(struct dm_event_handler *dmevh, const char *path);
  63.  
  64. /*
  65.  * Identify the device to monitor by exactly one of device_name, uuid or
  66.  * device number. String arguments are duplicated, see above.
  67.  */
  68. int dm_event_handler_set_dev_name(struct dm_event_handler *dmevh, const char *device_name);
  69.  
  70. int dm_event_handler_set_uuid(struct dm_event_handler *dmevh, const char *uuid);
  71.  
  72. void dm_event_handler_set_major(struct dm_event_handler *dmevh, int major);
  73. void dm_event_handler_set_minor(struct dm_event_handler *dmevh, int minor);
  74. void dm_event_handler_set_timeout(struct dm_event_handler *dmevh, int timeout);
  75.  
  76. /*
  77.  * Specify mask for events to monitor.
  78.  */
  79. void dm_event_handler_set_event_mask(struct dm_event_handler *dmevh,
  80.                      enum dm_event_mask evmask);
  81.  
  82. const char *dm_event_handler_get_dso(const struct dm_event_handler *dmevh);
  83. const char *dm_event_handler_get_dev_name(const struct dm_event_handler *dmevh);
  84. const char *dm_event_handler_get_uuid(const struct dm_event_handler *dmevh);
  85. int dm_event_handler_get_major(const struct dm_event_handler *dmevh);
  86. int dm_event_handler_get_minor(const struct dm_event_handler *dmevh);
  87. int dm_event_handler_get_timeout(const struct dm_event_handler *dmevh);
  88. enum dm_event_mask dm_event_handler_get_event_mask(const struct dm_event_handler *dmevh);
  89.  
  90. /* FIXME Review interface (what about this next thing?) */
  91. int dm_event_get_registered_device(struct dm_event_handler *dmevh, int next);
  92.  
  93. /*
  94.  * Initiate monitoring using dmeventd.
  95.  */
  96. int dm_event_register_handler(const struct dm_event_handler *dmevh);
  97. int dm_event_unregister_handler(const struct dm_event_handler *dmevh);
  98.  
  99. /* Prototypes for DSO interface, see dmeventd.c, struct dso_data for
  100.    detailed descriptions. */
  101. void process_event(struct dm_task *dmt, enum dm_event_mask evmask, void **user);
  102. int register_device(const char *device_name, const char *uuid, int major, int minor, void **user);
  103. int unregister_device(const char *device_name, const char *uuid, int major,
  104.               int minor, void **user);
  105.  
  106. #endif
  107.